namespace Domotica.Windows.Input
{
    using Microsoft.VisualBasic;
    using System;
    using System.ComponentModel;
    using System.Windows.Input;
    using System.Windows.Markup;

    public class SignBinding : InputBinding
    {
        public SignBinding()
        {
        }

        internal SignBinding(ICommand command, Domotica.Windows.Input.SignAction signAction) : this(command, new SignGesture(signAction))
        {
        }

        public SignBinding(ICommand command, SignGesture gesture) : base(command, gesture)
        {
        }

        [ValueSerializer(typeof(SignGestureValueSerializer)), TypeConverter(typeof(SignGestureConverter))]
        public override InputGesture Gesture
        {
            get
            {
                return (base.Gesture as SignGesture);
            }
            set
            {
                if (!(value is SignGesture))
                {
                    throw new ArgumentException("Expected type SignGesture");
                }
                base.Gesture = value;
            }
        }

        public Domotica.Windows.Input.SignAction SignAction
        {
            get
            {
                if (this.Gesture != null)
                {
                    return ((SignGesture) this.Gesture).SignAction;
                }
                return Domotica.Windows.Input.SignAction.None;
            }
            set
            {
                if (this.Gesture == null)
                {
                    this.Gesture = new SignGesture(value);
                }
                else
                {
                    ((SignGesture) this.Gesture).SignAction = value;
                }
            }
        }
    }
}

